package com.kust.smarthome.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kust.smarthome.web.mapper.WatchMapper;
import com.kust.smarthome.web.model.Watch;
import com.kust.smarthome.web.service.IWatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author iAuzre
 * @since 2021-07-06
 */
@Service
public class WatchServiceImpl extends ServiceImpl<WatchMapper, Watch> implements IWatchService {

    @Autowired
    private WatchMapper watchMapper;

    @Override
    public List<Watch> getByUserId(Integer userId) {
        QueryWrapper<Watch> query = new QueryWrapper<>();
        query.eq("user_id", userId);
        return watchMapper.selectList(query);
    }

    @Override
    public void insert(Watch watch) {
        watchMapper.insert(watch);
    }

    //获取家人智能表的信息
    @Override
    public String getContent(Integer watchId) {
        return watchMapper.selectContent(watchId);
    }
}
